import request from '@/utils/request'

const api_name = "/admin/product/baseTrademark"

export default {
    // DELETE /admin/product/baseTrademark/remove/{id}
    delete(id) {
        return request.delete(`${api_name}/remove/${id}`)
    },
    // PUT /admin/product/baseTrademark/update
    // POST /admin/product/baseTrademark/save
    // 添加和修改，最终都需要传递一个对象，请求具体参数
    /*
          {
              "id": 0,    // 可以根据id判断是否是添加还是修改
              "logoUrl": "string",
              "tmName": "string"
          }
    */
    addOrUpdate(trademark) {
        if (trademark.id) {
            return request.put(`${api_name}/update`, trademark)
        } else {
            return request.post(`${api_name}/save`, trademark)
        }
    },
    // GET /admin/product/baseTrademark/{page}/{limit}
    // GET /admin/product/baseTrademark/getTrademarkList
    getPageList(page, limit) {
        if (page && limit) {
            return request.get(`${api_name}/${page}/${limit}`)
        }
        return request.get(`${api_name}/getTrademarkList`)
    },
    // GET /admin/product/baseTrademark/get/{id}
    get(id) {
        return request.get(`${api_name}/get/${id}`)
    },
    // GET /admin/product/baseTrademark/findBaseTrademarkByKeyword/{keyword}
    findBaseTrademarkByKeyword(keyword) {
        return request({
            url: `${api_name}/findBaseTrademarkByKeyword/${keyword}`,
            method: "get"
        })
    }
}